//
// Created by 谢哲 on 2021/5/20.
//

#include <iostream>
#include <vector>
#include <map>
using namespace std;

class Edge {
public:
    long long y_down, y_up;
    bool left;
};

int main() {
    int n;
    cin >> n;
    map<long long, vector<Edge>> edge_data;
    for (int i=0;i<n;++i) {
        long long x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        Edge edge;
        edge.y_down = y2, edge.y_up = y1, edge.left = true;
        edge_data[x1].emplace_back(edge);
        edge.left = false;
        edge_data[x2].emplace_back(edge);
    }

    map<long long, int> cnt;
    long long last_left = 0, last_len = 0;
    long long ans = 0;
    for (auto &pos: edge_data) {
        long long x = pos.first;
        ans += last_len * (x - last_left);
        last_left = x;
        auto edge_list = pos.second;
        for (const auto &edge: edge_list) {
            if (edge.left) {
                cnt[edge.y_down]++, cnt[edge.y_up]--;
            }
            else {
                cnt[edge.y_down]--, cnt[edge.y_up]++;
            }
        }
        last_len = 0;
        long long last_y = 0;
        int y_cnt = 0;
        for (const auto &p: cnt) {
            int next_y_cnt = y_cnt + p.second;
            if (y_cnt == 0 && next_y_cnt > 0) {
                last_y = p.first;
            }
            else if (y_cnt > 0 && next_y_cnt <= 0) {
                last_len += p.first - last_y;
            }
            y_cnt = next_y_cnt;
        }
    }

    cout << ans;

    return 0;
}